<script type="text/javascript" charset="UTF-8">
	var ctrlTree;
	var graphTree;
	$(function() {
		ctrlTree = $('#ctrlTree').tree({
			url : '/main/menutree',
			lines : true,
			onClick : function(node) {
				addTab(node);
			},
			onDblClick : function(node) {
				if (node.state == 'closed') {
					$(this).tree('expand', node.target);
				} else {
					$(this).tree('collapse', node.target);
				}
			},
			/*页面加载就自动展开所有节点
			onLoadSuccess : function(node, data) {
				var t = $(this);
				if (data) {
					$(data).each(function(index, d) {
						if (this.state == 'closed') {
							t.tree('expandAll');
						}
					});
				}
			}
			*/
		});
	});
	
	function collapseAll() {
		var node = ctrlTree.tree('getSelected');
		if (node) {
			ctrlTree.tree('collapseAll', node.target);
		} else {
			ctrlTree.tree('collapseAll');
		}
	};
	function expandAll() {
		var node = ctrlTree.tree('getSelected');
		if (node) {
			ctrlTree.tree('expandAll', node.target);
		} else {
			ctrlTree.tree('expandAll');
		}
	};
	function collapsegraphTree() {
		var node = graphTree.tree('getSelected');
		if (node) {
			graphTree.tree('collapseAll', node.target);
		} else {
			graphTree.tree('collapseAll');
		}
	}
	function expandgraphTree() {
		var node = graphTree.tree('getSelected');
		if (node) {
			graphTree.tree('expandAll', node.target);
		} else {
			graphTree.tree('expandAll');
		}
	}
</script>

<div class="easyui-panel" fit="true" border="false">
	<div class="easyui-accordion" fit="true" border="false"  style="background:#f0f3f5;">
		<div title="系统菜单" iconCls="icon-tip">
			<div class="easyui-layout" fit="true">
				<div region="north" border="false" style="overflow: hidden;background:#f0f3f5;">
					<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-redo" onclick="expandAll();">展开</a><a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-undo" onclick="collapseAll();">折叠</a><a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-reload" onclick="ctrlTree.tree('reload');">刷新</a>
					<hr style="border-color: #fff;" />
				</div>
				<div region="center" border="false" style="background:#f0f3f5;">
					<ul id="ctrlTree" style="margin-top: 5px;"></ul>
				</div>
			</div>
		</div>
        
	</div>
</div>